{include file="public/head"/}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">添加广告位</div>
                <div class="layui-card-body" pad15>
                    <div class="layui-form" wid100 lay-filter="">

                        <div class="layui-form-item">
                            <label class="layui-form-label">名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" value="{$info.name|default=''}" lay-verify="required" placeholder="{:lang('pleaseEnter')}广告位名称" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">建议格式: 【首页】顶部通栏</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">{:lang('order')}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="sort" value="{$info.sort|default=''}"  lay-verify="required|number" placeholder="从小到大排序" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input type="hidden" name="ad_postion_id" value="{$info.ad_postion_id|default=''}">
                                <button class="layui-btn" lay-submit lay-filter="edit-but">确认保存</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/foot"/}
<script>
    layui.config({
        base: '__LAYDMIN__',{if config('app.app_debug')}version: true{/if}
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','table','form'],function(){
			var $ = layui.$, admin = layui.admin, table = layui.table, element = layui.element, form = layui.form,util = layui.util, upload = layui.upload;
			var uri="{if isset($id)}{:url(SYS_PATH.'/'.CONTROLLER.'/edit')}{else}{:url(SYS_PATH.'/'.CONTROLLER.'/add')}{/if}";
			form.on('submit(edit-but)', function (data) {
				admin.req({
					url: uri, 
					type: 'post',
					data: data.field, 
					success: function (res) {
						if(res.code==0){
							window.top.layer.msg(res.msg, {icon: 1, time: 1000,shade:[0.5,'#000000']}, function () {
								layer.closeAll("iframe");
								//刷新父页面
								parent.location.reload();
							});
						}else{
								window.top.layer.msg(res.msg, {icon: 2, time: 1000,shade:[0.5,'#000']});
								return;
						}
					}
				});
			});
	});
</script>
</body>
</html>